﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for StudentBUS
/// </summary>
public class StudentBUS
{
    private StudentDA student;

	public StudentBUS()
	{
		//
		// TODO: Add constructor logic here
		//
        student = new StudentDA();
	}
    public DataSet studentLogin(string username,string pass){
        return student.studentLogin(username, pass);
    }
    public DataSet getDesignByComp(int studentId, string compName)
    {
        return student.getDesignByComp(studentId,compName);
    }
    public DataSet getDesignByName(int studentId, string name)
    {
        return student.getDesignByName(studentId, name);
    }
    public bool insertDesign(Design d,byte[] images)
    {
        return student.insertDesign(d, images);
    }

    public bool updateDesign(Design d)
    {
        return student.updateDesign(d);
    }
    
    /*
     * xoa Design co designId
     * - xoa Mark co designId
     * - xoa Design co designId
     */
    //XONG
    public bool delDesign(Design d)
    {
        StaffDA staff = new StaffDA();
        Mark m = staff.getMarkByDesign(d);
        if (!staff.delMark(m))
        {
            return false;
        }
        return student.delDesign(d);
    }

    public DataSet getAllDesign(int id)
    {
        DataSet ds = student.getAllDesign(id);
        if (!(ds.Tables[0].Rows.Count > 0))
        {
            return null;
        }
        return ds;
    }
}